<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/3/8
 * Time: 15:13
 */
class Tool{
    private static $merCode;
    private static $time;
    private static $sign;
    /**
     * @param $merCode 商户号
     * @param $time 时间参数
     * @param $sign 签名
     * @return array
     */
    public static function checkSign($params,$floder,$key){
        $merCode = $params['merCode'];
        $time = $params['time'];
        $sign = $params['sign'];
        //$key = "032e71330511ad6aa3af0934662c9c35";
		//$key =$params['key'];
	
        $checkSign = md5("merCode=".$merCode."&floder=".$floder."&time=".$time."&0".$key);
        if($checkSign == $sign){
            $result = array('code' =>0,'msg'=>'ok','info'=>'成功');
            return $result;
        }else{
            $result = array('code' =>10001,'msg'=>'miss','info'=>'失败');
            return $result;
            exit;
        }
    }
    /**
     * @param $params
     * 参数校验
     */
    public static function checkUrlSign($params){
        $merCode = $params['merCode'];
        $muid = $params['muid'];
        $vid = $params['vid'];
        $time = $params['time'];
        //$key = md5($time);
	$key = "032e71330511ad6aa3af0934662c9c35";
        $sign = $params['sign'];
	
        $data = "merCode=".$merCode."&muid=".$muid."&vid=".$vid."&time=".$time."&0".$key;
        $checkSign = md5($data);
	//var_dump($data);die();
        if($sign==$checkSign){
            $result = array('code' =>0,'msg'=>'ok','info'=>'成功');
            return $result;
        }else{
            $result = array('code' =>10001,'msg'=>'miss','info'=>'失败');
            return $result;
        }

    }
    /**
     * @param $params
     * 必填参数校验
     */

    public static function mustParams($key,$params)
    {
        array_key_exists($key,$params);
    }
    /**
     *
     */
    public static function test(){
        echo 111;
    }


}
